/**
 * @FilePath     : /src/lgmg_robots/agv_navigation/agv_navigate/include/agvNavigate/opInclude/operation_charge.h
 * @Description  : 定义了OperationCharge类，该类继承自Operation类，主要用于处理充电操作的相关功能，
 *                 包括初始化、准备、开始、结束和执行操作。该类还包含与充电服务交互的客户端和充电IO的索引。  
 * @Author       : xiujun.yang
 * @Version      : 1.0.0
 * @LastEditors  : haibo haibo.yang@lgmgim.cn
 * @LastEditTime : 2024-12-19 16:33:08
 * @Copyright (c) 2024 by 临工智能信息科技有限公司, All Rights Reserved. 
**/ 
#pragma once
#include "operation.h"
#include <agv_srvs/srv/output_interface.hpp>
#include <agv_msgs/msg/output_port.hpp>
#include <agv_srvs/srv/battery_charge.hpp>
#define CHARGING_ACTION_TYPE "999"
//////////////////////////////////////////////////////////////////////////////
//   The interface of class "Operation".
class OperationCharge : public Operation
{
 public:
    explicit OperationCharge(const agv_msgs::msg::Action& action);

    // The destructor
    virtual ~OperationCharge() = default;

    // Initialize the related data
    virtual bool Init() override;

    // Ready to start new op
    virtual bool ReadyStart() override;

    // Defines how to start the operation
    virtual bool StartAction() override;

    // Defines how to end the operation
    virtual bool EndAction() override;

    // Defines how to do the operation
    virtual bool Work() override;

 private:
    bool SetChargeIoOut(bool open); 
    rclcpp::Client<agv_srvs::srv::BatteryCharge>::SharedPtr client_; // Client for charging service
    int charge_io_index_;               // Index of charging io
};

